package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JyjcAuditList;
import com.ruoyi.system.service.IJyjcAuditListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报销分摊审核记录Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@RestController
@RequestMapping("/system/JyjcAuditList")
public class JyjcAuditListController extends BaseController
{
    @Autowired
    private IJyjcAuditListService jyjcAuditListService;

    /**
     * 查询报销分摊审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcAuditList:list')")
    @GetMapping("/list")
    public TableDataInfo list(JyjcAuditList jyjcAuditList)
    {
        startPage();
        List<JyjcAuditList> list = jyjcAuditListService.selectJyjcAuditListList(jyjcAuditList);
        return getDataTable(list);
    }
    @Anonymous
    @GetMapping("/getAudit")
    public AjaxResult getAudit(JyjcAuditList jyjcAuditList)
    {

        List<JyjcAuditList> list = jyjcAuditListService.selectJyjcAuditListList(jyjcAuditList);
        return success(list.get(0));
    }
    /**
     * 导出报销分摊审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcAuditList:export')")
    @Log(title = "报销分摊审核记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JyjcAuditList jyjcAuditList)
    {
        List<JyjcAuditList> list = jyjcAuditListService.selectJyjcAuditListList(jyjcAuditList);
        ExcelUtil<JyjcAuditList> util = new ExcelUtil<JyjcAuditList>(JyjcAuditList.class);
        util.exportExcel(response, list, "报销分摊审核记录数据");
    }

    /**
     * 获取报销分摊审核记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcAuditList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jyjcAuditListService.selectJyjcAuditListById(id));
    }

    /**
     * 新增报销分摊审核记录
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcAuditList:add')")
    @Log(title = "报销分摊审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JyjcAuditList jyjcAuditList)
    {
        return toAjax(jyjcAuditListService.insertJyjcAuditList(jyjcAuditList));
    }

    /**
     * 修改报销分摊审核记录
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcAuditList:edit')")
    @Log(title = "报销分摊审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JyjcAuditList jyjcAuditList)
    {
        return toAjax(jyjcAuditListService.updateJyjcAuditList(jyjcAuditList));
    }
    @Anonymous
    @PostMapping("/updateAudit")
    public AjaxResult updateAudit(@RequestBody JyjcAuditList jyjcAuditList)
    {
        return toAjax(jyjcAuditListService.updateJyjcAuditList(jyjcAuditList));
    }
    /**
     * 删除报销分摊审核记录
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcAuditList:remove')")
    @Log(title = "报销分摊审核记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jyjcAuditListService.deleteJyjcAuditListByIds(ids));
    }
}
